package com.fog.judge.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fog.judge.common.UserContext;
import com.fog.judge.entity.Course;
import com.fog.judge.entity.QualitativeEvaluations;
import com.fog.judge.mapper.CourseMapper;
import com.fog.judge.mapper.QualitativeEvaluationsMapper;
import com.fog.judge.service.CourseService;
import com.fog.judge.service.QualitativeEvaluationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class QualitativeEvaluationsServiceImpl extends ServiceImpl<QualitativeEvaluationsMapper, QualitativeEvaluations> implements QualitativeEvaluationsService {

    @Resource
    private QualitativeEvaluationsService qualitativeEvaluationsService;

    @Override
    public boolean hasEvaluator(int currentId, int teacherId) {
        LambdaQueryWrapper<QualitativeEvaluations> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(QualitativeEvaluations::getTeacherId, teacherId).eq(QualitativeEvaluations::getEvalutorId, currentId);
        return this.baseMapper.selectCount(queryWrapper) > 0;
    }

    @Override
    public List<QualitativeEvaluations> getQualitativeEvaluationsByTeacherId(int userId) {
        LambdaQueryWrapper<QualitativeEvaluations> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(QualitativeEvaluations::getTeacherId, userId);
        return this.baseMapper.selectList(queryWrapper);
    }

}
